<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<chiptrack:checkLogon sourcePage="endUser.do"/>
<%@ page import="com.scalar.chiptrack.utils.ConfigManager"%>
<%@ page import="com.scalar.chiptrack.commons.SessionKeys"%>
<%@ page import="com.scalar.chiptrack.commons.Constants"%>
<%@ page import="com.scalar.chiptrack.users.Functionality"%>
<%@ page import="com.scalar.chiptrack.users.User"%>
<%@ page import="java.util.ArrayList"%>
<%@ page import="java.util.HashMap"%>
<%@ page import="java.util.Iterator"%>
<%@ page import="com.scalar.chiptrack.sales.ContactPerson"%>
<%@ page import="com.scalar.chiptrack.sales.dao.CustomerDAO"%>
<%@ page import="com.scalar.chiptrack.sales.forms.CustomerForm"%>
<%@ page import="com.scalar.chiptrack.sales.Customer"%>




<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>
<% User user1 = (User) session.getAttribute (SessionKeys.USER_KEY); %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML><HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type=text/css rel=stylesheet>

<META content="MSHTML 5.50.4807.2300" name=GENERATOR>

</HEAD>
<BODY bgColor="#ffffff" leftMargin=0 topMargin=0 marginheight="0" marginwidth="0" onload="load();">

<script src="<%=chipTracContext%>/jsp/includes/scripts/functions.js"></script>
<SCRIPT language="JavaScript" src="<%=chipTracContext%>/jsp/includes/scripts/validations.js"></script>


<script language="JavaScript">
<%
    HashMap contactPersonsList = (HashMap)session.getAttribute("contactPersonsMap");
    if(contactPersonsList != null)
    {
        int listSize = contactPersonsList.size();
        java.util.Iterator contactPersonsIterator = contactPersonsList.keySet().iterator();
        ContactPerson contactPersons[] = new ContactPerson[listSize];
		%>
			var contactPerson = new Array(<%=listSize%>);
			var phNo          = new Array(<%=listSize%>);
			var cellNo        = new Array(<%=listSize%>);
			var fax           = new Array(<%=listSize%>);
			var email         = new Array(<%=listSize%>);
			var address       = new Array(<%=listSize%>);
			contactPerson[-3] = '';
			contactPerson[-2] = -1;
			contactPerson[-1] = '';
        <%
        for( int aa = 0; aa < listSize ; aa++)
        {
           Object key = (String)contactPersonsIterator.next();
           if( contactPersonsList.get(key)!= null )
            {
                if(contactPersonsList.containsKey(key))
                {
                    contactPersons[aa] = (ContactPerson)contactPersonsList.get(key);
					%>
						contactPerson[<%=aa%>] = '<%=contactPersons[aa].getContactPerson().replaceAll("'","\\\\" + "'")%>';
						phNo[<%=aa%>]          = '<%=contactPersons[aa].getPhoneNumber().replaceAll("'","\\\\" + "'")%>';
						cellNo[<%=aa%>]        = '<%=contactPersons[aa].getCellNumber().replaceAll("'","\\\\" + "'")%>';
						fax[<%=aa%>]           = '<%=contactPersons[aa].getFaxNumber().replaceAll("'","\\\\" + "'")%>';
						email[<%=aa%>]		   = '<%=contactPersons[aa].getEmail()%>';
						address[<%=aa%>]	   = '<%=contactPersons[aa].getAddress().replaceAll("'","\\\\" + "'")%>';
					<%
               }
           }

       } //for

   }
%>

//Added by Sarada on 7th April 2004
<% 
    HashMap billContactPersonsList = (HashMap)session.getAttribute("billingContactPersonsMap");
    if(billContactPersonsList != null)
    {
        int billListSize = billContactPersonsList.size();
        java.util.Iterator billContactPersonsIterator = billContactPersonsList.keySet().iterator();
        ContactPerson billContactPersons[] = new ContactPerson[billListSize];
        %>
            var billContactPerson = new Array(<%=billListSize%>);
            var billPhNo          = new Array(<%=billListSize%>);
            var billCellNo        = new Array(<%=billListSize%>);
            var billFax           = new Array(<%=billListSize%>);
            var billEmail         = new Array(<%=billListSize%>);
            billContactPerson[-3] = '';
            billContactPerson[-2] = -1;
            billContactPerson[-1] = '';
        <%
        for( int bb = 0; bb < billListSize ; bb++)
        {
           Object key = (String)billContactPersonsIterator.next();
           if( billContactPersonsList.get(key)!= null )
            {
                if(billContactPersonsList.containsKey(key))
                {
                    billContactPersons[bb] = (ContactPerson)billContactPersonsList.get(key);
                    %>
                        billContactPerson[<%=bb%>] = '<%=billContactPersons[bb].getContactPerson().replaceAll("'","\\\\" + "'")%>';
                        billPhNo[<%=bb%>]          = '<%=billContactPersons[bb].getPhoneNumber().replaceAll("'","\\\\" + "'")%>';
                        billCellNo[<%=bb%>]        = '<%=billContactPersons[bb].getCellNumber().replaceAll("'","\\\\" + "'")%>';
                        billFax[<%=bb%>]           = '<%=billContactPersons[bb].getFaxNumber().replaceAll("'","\\\\" + "'")%>';
                        billEmail[<%=bb%>]         = '<%=billContactPersons[bb].getEmail()%>';
                    <%
               }
           }
       } //for
   }
%>

//Added by Sarada on 7th April 2004
<% 
    HashMap shipContactPersonsList = (HashMap)session.getAttribute("shippingContactPersonsMap");
    if(shipContactPersonsList != null)
    {
        int shipListSize = shipContactPersonsList.size();
        java.util.Iterator shipContactPersonsIterator = shipContactPersonsList.keySet().iterator();
        ContactPerson shipContactPersons[] = new ContactPerson[shipListSize];
        %>
            var shipContactPerson = new Array(<%=shipListSize%>);
            var shipPhNo          = new Array(<%=shipListSize%>);
            var shipCellNo        = new Array(<%=shipListSize%>);
            var shipFax           = new Array(<%=shipListSize%>);
            var shipEmail         = new Array(<%=shipListSize%>);
            shipContactPerson[-3] = '';
            shipContactPerson[-2] = -1;
            shipContactPerson[-1] = '';
        <%
        for( int dd = 0; dd < shipListSize ; dd++)
        {
           Object key = (String)shipContactPersonsIterator.next();
           if( shipContactPersonsList.get(key)!= null )
            {
                if(shipContactPersonsList.containsKey(key))
                {
                    shipContactPersons[dd] = (ContactPerson)shipContactPersonsList.get(key);
                    %>
                        shipContactPerson[<%=dd%>] = '<%=shipContactPersons[dd].getContactPerson().replaceAll("'","\\\\" + "'")%>';
                        shipPhNo[<%=dd%>]          = '<%=shipContactPersons[dd].getPhoneNumber().replaceAll("'","\\\\" + "'")%>';
                        shipCellNo[<%=dd%>]        = '<%=shipContactPersons[dd].getCellNumber().replaceAll("'","\\\\" + "'")%>';
                        shipFax[<%=dd%>]           = '<%=shipContactPersons[dd].getFaxNumber().replaceAll("'","\\\\" + "'")%>';
                        shipEmail[<%=dd%>]         = '<%=shipContactPersons[dd].getEmail()%>';
                    <%
               }
           }
       } //for
   }
%>

function contactPersonss( contactPersonName, phNo, cellNo, fax, email )
{
	this.contactPersonName = contactPersonName;
	this.phNo = phNo;
	this.cellNo = cellNo;
	this.fax = fax;
	this.email = email;
}

//Added by Sarada on 9th April 2004
<% 
    HashMap allContactPersonsList = (HashMap)session.getAttribute("allShippingContactPersonsMap");
    if(allContactPersonsList != null)
    {
        int mapSize = allContactPersonsList.size();
        java.util.Iterator allContactPersonsIterator = allContactPersonsList.keySet().iterator();
		HashMap[] allContactPersons = new HashMap[mapSize];
		String[] addressId = new String[mapSize];
		%> 
			var addId = new Array(<%=mapSize%>); 
			var shippingAddressArray = new Array(<%=mapSize%>);
		<%
		for( int bb = 0; bb < mapSize ; bb++)
        {
             addressId[bb] = (String)allContactPersonsIterator.next();

		   %>  
			    addId[<%=bb%>] =  '<%=addressId[bb]%>';
		   <%
		   
           if( allContactPersonsList.get(addressId[bb]) != null )
            {
                if(allContactPersonsList.containsKey(addressId[bb]))
                {
					allContactPersons[bb] = (HashMap) allContactPersonsList.get(addressId[bb]);
					if( allContactPersons[bb]  != null )
					{
						int[] contactPersonsSize = new int[mapSize];
						contactPersonsSize[bb] = allContactPersons[bb].size();
						//System.out.println("contactPersonsSize  "+contactPersonsSize[bb]);
						Iterator[] contactPersonsIterator = new Iterator[mapSize];
						contactPersonsIterator[bb] = allContactPersons[bb].keySet().iterator();
						
						%>
						    var contactPersonArray = new Array(<%=contactPersonsSize[bb]%>);
						<%
						for( int cc = 0; cc < contactPersonsSize[bb] ; cc++)
						{
							 Object[] key = new Object[mapSize];
							 key[bb] = (String)contactPersonsIterator[bb].next();
							 ContactPerson contactPersons[] = new ContactPerson[contactPersonsSize[bb]];
							if( allContactPersons[bb].get(key[bb]) != null )
							{
								if( allContactPersons[bb].containsKey(key[bb]) )
								{
									contactPersons[cc]	=  (ContactPerson)allContactPersons[bb].get(key[bb]);
									%>
									   contactPersonArray[<%=cc%>]= new contactPersonss('<%=contactPersons[cc].getContactPerson().replaceAll("'","\\\\" + "'")%>',
																						'<%=contactPersons[cc].getPhoneNumber().replaceAll("'","\\\\" + "'")%>',
																						'<%=contactPersons[cc].getCellNumber().replaceAll("'","\\\\" + "'")%>',
																						'<%=contactPersons[cc].getFaxNumber().replaceAll("'","\\\\" + "'")%>',
																						'<%=contactPersons[cc].getEmail()%>');		
									<%
								}
							}	

						}//for
						
					}//if( allContactPersons != null )
				
				}//if
			}//if
			 %>	 shippingAddressArray[<%=bb%>] = contactPersonArray ;  <%

        } //for
    }
%>





    function load() {

	     var locsize = document.getElementById('locSize').value;
         // Added by Veeru on 1st Oct 2004 to persist the sameas value when form is reset
        var sameas = '<%=request.getParameter("sameas")%>'
        if( sameas == "yes" )
        {
            document.endUserForm.sameas.checked = true;
        }
        // End of added by Veeru
		for( aa = 0; aa < locsize; aa++)
		{
			if( document.endUserForm['endUser.shippingLocations['+aa+'].contactPerson'].value == '' ||    document.endUserForm['endUser.shippingLocations['+aa+'].contactPerson'].value == -1)
			{
				document.endUserForm['endUser.shippingLocations['+aa+'].contactPersonObject.phoneNumber'].disabled = true;
				document.endUserForm['endUser.shippingLocations['+aa+'].contactPersonObject.cellNumber'].disabled = true;

				document.endUserForm['endUser.shippingLocations['+aa+'].contactPersonObject.faxNumber'].disabled = true;
				document.endUserForm['endUser.shippingLocations['+aa+'].contactPersonObject.email'].disabled = true;
			}
		}

		if( document.endUserForm['endUser.billingAddress.contactPerson'].value == '' || document.endUserForm['endUser.billingAddress.contactPerson'].value == -1 )
		{
			document.endUserForm['endUser.billingContactPersonObject.phoneNumber'].disabled = true;
			document.endUserForm['endUser.billingContactPersonObject.cellNumber'].disabled = true;
			document.endUserForm['endUser.billingContactPersonObject.faxNumber'].disabled = true;
			document.endUserForm['endUser.billingContactPersonObject.email'].disabled = true;
		}

		if( document.endUserForm['endUser.shippingAddress.contactPerson'].value == '' || document.endUserForm['endUser.shippingAddress.contactPerson'].value == -1 )
		{
			document.endUserForm['endUser.shippingContactPersonObject.phoneNumber'].disabled = true;
			document.endUserForm['endUser.shippingContactPersonObject.cellNumber'].disabled = true;
			document.endUserForm['endUser.shippingContactPersonObject.faxNumber'].disabled = true;
			document.endUserForm['endUser.shippingContactPersonObject.email'].disabled = true;
		}


          /*  if( document.endUserForm['endUser.billingAddress.contactPerson'].value == '' || document.endUserForm['endUser.billingAddress.contactPerson'].value == -1 )
            {
                 document.endUserForm['endUser.contactPersonObject.phoneNumber'].disabled = true;
                 document.endUserForm['endUser.contactPersonObject.cellNumber'].disabled = true;
                 document.endUserForm['endUser.contactPersonObject.faxNumber'].disabled = true;
                 document.endUserForm['endUser.contactPersonObject.email'].disabled = true;
                // document.endUserForm['endUser.contactPersonObject.address'].disabled = true;


            }*/


   }
   function submitpage(theForm)
   {
        var errors = '';
        var i=0;
        var a = document.getElementById('locSize').value;

        var endUser = document.endUserForm['endUser.endUserName'];

        var shippingemail = document.endUserForm['endUser.shippingContactPersonObject.email'];

        if( (trim(endUser.value) == '') || (trim(endUser.value).length == 0) )
        {
            errors = 'Please enter End User Name';
        }

    	if( document.endUserForm['endUser.billingAddress.contactPerson'].value != '' )
        {
            var contactPersonEmail = document.endUserForm['endUser.billingContactPersonObject.email'];
           if( contactPersonEmail.value != '' )
	       {
            if( !IsValidEmail (contactPersonEmail) )
            {
               errors = '<li>'+'Please enter a valid email address';
               contactPersonEmail.select();
               contactPersonEmail.focus();
            }
          }
        }
        if( shippingemail.value != '' )
	    {
            if( !IsValidEmail (shippingemail) )
            {
               errors = '<li>'+'Please enter a valid email address';
               shippingemail.select();
               shippingemail.focus();
            }
         }
        i=0;
        while(i < a)
        {
            var email = document.endUserForm['endUser.shippingLocations['+i+'].contactPersonObject.email'];
          if( email.value != '' )
	      {
            if( !IsValidEmail (email) )
            {
               errors = '<li>'+'Please enter a valid email address';
               email.select();
               email.focus();
            }
          }
          i++;
        }

        if(errors != '')
        {
            var inf = document.getElementById("infoMessagesId");
            inf.innerHTML = '';
            var err = document.getElementById("errorMessagesId");
            err.innerHTML = '';

            var pa=document.getElementById("errors");
            pa.innerHTML = errors;
            return ;
        }

        i=0;
        while(i < a)
        {
            if(document.endUserForm['endUser.shippingLocations['+i+'].defaultAddress'].checked == true)
            {
                if(trim(document.endUserForm['endUser.shippingLocations['+i+'].address1'].value).length == 0)
                {
                    var pa=document.getElementById("errors");
                    pa.innerHTML = '<li> Address cannot be blank if a Shipping Address is selected as Default Shipping Address';
                    document.endUserForm['endUser.shippingLocations['+i+'].address1'].focus();
                    return ;
                }
                //Added by Sarada on 28th Jan 2004
                if( document.endUserForm['endUser.shippingLocations['+i+'].defaultAddress'].checked == true
                && document.endUserForm['endUser.shippingLocations['+i+'].remove'].checked == true )
                {

                     var pa1=document.getElementById("errors");
                     pa1.innerHTML = '<li> Both  Remove and DefaultShippingAddress should not be selected ';
                     return ;
                }

            }
            i++;
        }
        var found = 0;
        for ( var i = 0; i < a ; i++ )
        {
            if( document.endUserForm['endUser.shippingLocations['+i+'].defaultAddress'].checked == true )
              { found++;}
        }
        if ( found > 1)
        {
             var pa=document.getElementById("errors");
             pa.innerHTML = '<br>'+'Select only one default shipping Address';
             return
        }


        theForm.action.value = "SaveEndUser";
        theForm.submit();
        return ;
   }

    function applyBillingAddress()
    {
        if( document.endUserForm.sameas.checked == true )   //Added by sarada on 28th Jan 2004
        {
            document.endUserForm['endUser.shippingAddress.address1'].value = document.endUserForm['endUser.billingAddress.address1'].value;
            document.endUserForm['endUser.shippingAddress.address2'].value = document.endUserForm['endUser.billingAddress.address2'].value;
            document.endUserForm['endUser.shippingAddress.address3'].value = document.endUserForm['endUser.billingAddress.address3'].value;
            document.endUserForm['endUser.shippingAddress.address4'].value = document.endUserForm['endUser.billingAddress.address4'].value;
            document.endUserForm['endUser.shippingAddress.city'].value = document.endUserForm['endUser.billingAddress.city'].value;
            document.endUserForm['endUser.shippingAddress.state'].value = document.endUserForm['endUser.billingAddress.state'].value;
            document.endUserForm['endUser.shippingAddress.zipCode'].value = document.endUserForm['endUser.billingAddress.zipCode'].value;
            document.endUserForm['endUser.shippingAddress.country'].value = document.endUserForm['endUser.billingAddress.country'].value;
         }

    }

     //Added by Sarada on 14th March 2004
   function selectContactPerson (element,idValue, indexValue)
   {
        if( element =='EndUserContactPerson' )
	    {
			for( ss = 0; ss < contactPerson.length; ss++ )
			{

				if( document.endUserForm['endUser.contactPerson'].value == contactPerson[ss] )
				{
					 document.endUserForm['endUser.contactPerson'].value = contactPerson[ss];
					 document.endUserForm['endUser.contactPersonObject.phoneNumber'].value = phNo[ss];
					 document.endUserForm['endUser.contactPersonObject.cellNumber'].value = cellNo[ss];
					 document.endUserForm['endUser.contactPersonObject.faxNumber'].value = fax[ss];
					 document.endUserForm['endUser.contactPersonObject.email'].value = email[ss];

					 document.endUserForm['endUser.contactPersonObject.phoneNumber'].disabled = false;
					 document.endUserForm['endUser.contactPersonObject.cellNumber'].disabled = false;
					 document.endUserForm['endUser.contactPersonObject.faxNumber'].disabled = false;
					 document.endUserForm['endUser.contactPersonObject.email'].disabled = false;
				}
				else  if( document.endUserForm['endUser.contactPerson'].value == '' )
				{
					 document.endUserForm['endUser.contactPerson'].value = '';
					 document.endUserForm['endUser.contactPersonObject.phoneNumber'].value = '';
					 document.endUserForm['endUser.contactPersonObject.cellNumber'].value = '';
					 document.endUserForm['endUser.contactPersonObject.faxNumber'].value = '';
					 document.endUserForm['endUser.contactPersonObject.email'].value = '';

					 document.endUserForm['endUser.contactPersonObject.phoneNumber'].disabled = true;
					 document.endUserForm['endUser.contactPersonObject.cellNumber'].disabled = true;
					 document.endUserForm['endUser.contactPersonObject.faxNumber'].disabled = true;
					 document.endUserForm['endUser.contactPersonObject.email'].disabled = true;
				}
			}
				if(document.endUserForm['endUser.contactPerson'].value == -1)
				{
					var customerId = document.endUserForm['endUser.customerId'].value ;

					newWindow = window.open ('<%=chipTracContext%>/addNewContactPerson.do?value=EndUser&customerId='+customerId,'endUserOptionsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=yes,scrollbars=yes,width=500,height=500,resizable=no');
					if(!newWindow.opener) {newWindow.opener = window}
					newWindow.focus();

					 document.endUserForm['endUser.contactPersonObject.phoneNumber'].value = '';
					 document.endUserForm['endUser.contactPersonObject.cellNumber'].value = '';
					 document.endUserForm['endUser.contactPersonObject.faxNumber'].value = '';
					 document.endUserForm['endUser.contactPersonObject.email'].value = '';

				 }

		} //if( element =='EndUserContactPerson' )

		if( element =='BillingContactPerson' )
		{

			 for( pp = 0; pp < billContactPerson.length; pp++ )
			 {
				if( document.endUserForm['endUser.billingAddress.contactPerson'].value == billContactPerson[pp] )
				{
					 document.endUserForm['endUser.billingAddress.contactPerson'].value = billContactPerson[pp];

					 document.endUserForm['endUser.billingContactPersonObject.phoneNumber'].value = billPhNo[pp];
					 document.endUserForm['endUser.billingContactPersonObject.cellNumber'].value = billCellNo[pp];
					 document.endUserForm['endUser.billingContactPersonObject.faxNumber'].value = billFax[pp];
					 document.endUserForm['endUser.billingContactPersonObject.email'].value = billEmail[pp];

					 document.endUserForm['endUser.billingContactPersonObject.phoneNumber'].disabled = false;
					 document.endUserForm['endUser.billingContactPersonObject.cellNumber'].disabled = false;
					 document.endUserForm['endUser.billingContactPersonObject.faxNumber'].disabled = false;
					 document.endUserForm['endUser.billingContactPersonObject.email'].disabled = false;
				}
				else
				if( document.endUserForm['endUser.billingAddress.contactPerson'].value == '' )
				{
					 document.endUserForm['endUser.billingAddress.contactPerson'].value = '';
					 document.endUserForm['endUser.billingContactPersonObject.phoneNumber'].value = '';
					 document.endUserForm['endUser.billingContactPersonObject.cellNumber'].value = '';
					 document.endUserForm['endUser.billingContactPersonObject.faxNumber'].value = '';
					 document.endUserForm['endUser.billingContactPersonObject.email'].value = '';

					 document.endUserForm['endUser.billingContactPersonObject.phoneNumber'].disabled = true;
					 document.endUserForm['endUser.billingContactPersonObject.cellNumber'].disabled = true;
					 document.endUserForm['endUser.billingContactPersonObject.faxNumber'].disabled = true;
					 document.endUserForm['endUser.billingContactPersonObject.email'].disabled = true;

				}
			 }

			if( document.endUserForm['endUser.billingAddress.contactPerson'].value == -1)
			{
				var billingAddressId = document.endUserForm['endUser.defaultBillingAddressId'].value ;
				var contactPerson1 = document.endUserForm['endUser.billingAddress.contactPerson'].value;
				//alert('bill'+billingAddressId);

				if (billingAddressId == -1)
                {
					billingAddressId = document.endUserForm['endUser.billAddressId'].value;
				}

                // Commented by SureshReddy on [09 JUNE 2004] to modify "width=500" to "width=550"
				// newWindow = window.open ('<%=chipTracContext%>/addNewEndUserContactPerson.do?value=Address&endUserId='+billingAddressId,'endUserOptionsPopup1','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=yes,scrollbars=yes,width=500,height=500,resizable=no');
                // Modified "width=500" to "width=550" by SureshReddy on [09 JUNE 2004] for alignment
				newWindow = window.open ('<%=chipTracContext%>/addNewEndUserContactPerson.do?value=Address&endUserId='+billingAddressId,'endUserOptionsPopup1','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=yes,scrollbars=yes,width=550,height=500,resizable=no');
				if(!newWindow.opener) {newWindow.opener = window}
				newWindow.focus();

				 document.endUserForm['endUser.billingAddress.contactPerson'].value = '';
				 document.endUserForm['endUser.billingContactPersonObject.phoneNumber'].value = '';
				 document.endUserForm['endUser.billingContactPersonObject.cellNumber'].value = '';
				 document.endUserForm['endUser.billingContactPersonObject.faxNumber'].value = '';
				 document.endUserForm['endUser.billingContactPersonObject.email'].value = '';
			}
		}//if( element =='BillingContactPerson' )

		if( element =='ShippingContactPerson' )
		{

			 for( ff = 0; ff < shipContactPerson.length; ff++ )
			 {
				if( document.endUserForm['endUser.shippingAddress.contactPerson'].value == shipContactPerson[ff] )
				{
					 document.endUserForm['endUser.shippingAddress.contactPerson'].value = shipContactPerson[ff];

					 document.endUserForm['endUser.shippingContactPersonObject.phoneNumber'].value = shipPhNo[ff];
					 document.endUserForm['endUser.shippingContactPersonObject.cellNumber'].value = shipCellNo[ff];
					 document.endUserForm['endUser.shippingContactPersonObject.faxNumber'].value = shipFax[ff];
					 document.endUserForm['endUser.shippingContactPersonObject.email'].value = shipEmail[ff];

					 document.endUserForm['endUser.shippingContactPersonObject.phoneNumber'].disabled = false;
					 document.endUserForm['endUser.shippingContactPersonObject.cellNumber'].disabled = false;
					 document.endUserForm['endUser.shippingContactPersonObject.faxNumber'].disabled = false;
					 document.endUserForm['endUser.shippingContactPersonObject.email'].disabled = false;
				}
				else
				if( document.endUserForm['endUser.shippingAddress.contactPerson'].value == '' )
				{
					 document.endUserForm['endUser.shippingAddress.contactPerson'].value = '';
					 document.endUserForm['endUser.shippingContactPersonObject.phoneNumber'].value = '';
					 document.endUserForm['endUser.shippingContactPersonObject.cellNumber'].value = '';
					 document.endUserForm['endUser.shippingContactPersonObject.faxNumber'].value = '';
					 document.endUserForm['endUser.shippingContactPersonObject.email'].value = '';

					 document.endUserForm['endUser.shippingContactPersonObject.phoneNumber'].disabled = true;
					 document.endUserForm['endUser.shippingContactPersonObject.cellNumber'].disabled = true;
					 document.endUserForm['endUser.shippingContactPersonObject.faxNumber'].disabled = true;
					 document.endUserForm['endUser.shippingContactPersonObject.email'].disabled = true;

				}
			 }

			if( document.endUserForm['endUser.shippingAddress.contactPerson'].value == -1)
			{
				var shippingAddressId = document.endUserForm['endUser.defaultShippingAddressId'].value ;
				var contactPerson1 = document.endUserForm['endUser.shippingAddress.contactPerson'].value;
				//alert(shippingAddressId);
				if (shippingAddressId == -1)
                {
					shippingAddressId = document.endUserForm['endUser.shipAddressId'].value;
				}

                // Commented by SureshReddy on [09 JUNE 2004] to modify "width=500" to "width=550"
				// newWindow = window.open ('<%=chipTracContext%>/addNewEndUserContactPerson.do?value=Address&endUserId='+shippingAddressId,'endUserOptionsPopup2','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=yes,scrollbars=yes,width=500,height=500,resizable=no');
                // Modified "width=500" to "width=550" by SureshReddy on [09 JUNE 2004] for alignment
				newWindow = window.open ('<%=chipTracContext%>/addNewEndUserContactPerson.do?value=Address&endUserId='+shippingAddressId,'endUserOptionsPopup2','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=yes,scrollbars=yes,width=550,height=500,resizable=no');
				if(!newWindow.opener) {newWindow.opener = window}
				newWindow.focus();

				 document.endUserForm['endUser.shippingAddress.contactPerson'].value = '';
				 document.endUserForm['endUser.shippingContactPersonObject.phoneNumber'].value = '';
				 document.endUserForm['endUser.shippingContactPersonObject.cellNumber'].value = '';
				 document.endUserForm['endUser.shippingContactPersonObject.faxNumber'].value = '';
				 document.endUserForm['endUser.shippingContactPersonObject.email'].value = '';
			}
		}//if( element =='ShippingContactPerson' )
		if( element =='ShippingLocationContactPerson' )
	    {
			var selectedContactPerson = document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPerson'].value;
			var customerId = document.endUserForm['endUser.customerId'].value ;
			var id = document.endUserForm['endUser.shippingLocations['+indexValue+'].locAddressId'].value;

			var someValue = new Array();
			for( ss = 0;ss < shippingAddressArray.length; ss++)
			{
				if( customerId == -1)
				{

					if( addId[ss] == id )
					{
						someValue = shippingAddressArray[ss];
						var  cpValue = new Array();
						for( aa =0 ; aa <someValue.length ; aa++)
						{
							cpValue[aa] = someValue[aa];
							if( cpValue[aa].contactPersonName == selectedContactPerson )
							{
								document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPerson'].value = cpValue[aa].contactPersonName;
								document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.phoneNumber'].value = cpValue[aa].phNo;
								document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.cellNumber'].value = cpValue[aa].cellNo;

								document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.faxNumber'].value = cpValue[aa].fax;
								document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.email'].value = cpValue[aa].email;


								document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.phoneNumber'].disabled = false;
								document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.cellNumber'].disabled = false;
								document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.faxNumber'].disabled = false;
								document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.email'].disabled = false;

							}
							else
							if(selectedContactPerson == '')
							{
								document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPerson'].value = '';
								document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.phoneNumber'].value = '';
								document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.cellNumber'].value = '';

								document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.faxNumber'].value = '';
								document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.email'].value = '';


								document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.phoneNumber'].disabled = true;
								document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.cellNumber'].disabled = true;
								document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.faxNumber'].disabled = true;
								document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.email'].disabled = true;


							}
						}//for
					}//if
				 }//if( customerId == -1)
				 else
				{
                    if( addId[ss] < 0 )
					{
						if( addId[ss] == id )
						{
							someValue = shippingAddressArray[ss];
							var  cpValue = new Array();
							for( aa =0 ; aa <someValue.length ; aa++)
							{
								cpValue[aa] = someValue[aa];
								if( cpValue[aa].contactPersonName == selectedContactPerson )
								{
									document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPerson'].value = cpValue[aa].contactPersonName;
									document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.phoneNumber'].value = cpValue[aa].phNo;
									document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.cellNumber'].value = cpValue[aa].cellNo;

									document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.faxNumber'].value = cpValue[aa].fax;
									document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.email'].value = cpValue[aa].email;

									document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.phoneNumber'].disabled = false;
									document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.cellNumber'].disabled = false;
									document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.faxNumber'].disabled = false;
									document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.email'].disabled = false;

								}
								else
								if(selectedContactPerson == '')
								{
									document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPerson'].value = '';
									document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.phoneNumber'].value = '';
									document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.cellNumber'].value = '';

									document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.faxNumber'].value = '';
									document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.email'].value = '';

									document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.phoneNumber'].disabled = true;
									document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.cellNumber'].disabled = true;
									document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.faxNumber'].disabled = true;
									document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.email'].disabled = true;

								}
							}//for
						}//if
					}//if
							else  if( addId[ss] > 0 )
							{
								if( addId[ss] == idValue )
								{
									someValue = shippingAddressArray[ss];
									var  cpValue = new Array();
									for( aa =0 ; aa <someValue.length ; aa++)
									{
										cpValue[aa] = someValue[aa];
										if( cpValue[aa].contactPersonName == selectedContactPerson )
										{
											document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPerson'].value = cpValue[aa].contactPersonName;
											document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.phoneNumber'].value = cpValue[aa].phNo;
											document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.cellNumber'].value = cpValue[aa].cellNo;

											document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.faxNumber'].value = cpValue[aa].fax;
											document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.email'].value = cpValue[aa].email;


											document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.phoneNumber'].disabled = false;
											document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.cellNumber'].disabled = false;
											document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.faxNumber'].disabled = false;
											document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.email'].disabled = false;


										}
										else
										if(selectedContactPerson == '')
										{
											document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPerson'].value = '';
											document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.phoneNumber'].value = '';
											document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.cellNumber'].value = '';

											document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.faxNumber'].value = '';
											document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.email'].value = '';

											document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.phoneNumber'].disabled = true;
											document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.cellNumber'].disabled = true;
											document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.faxNumber'].disabled = true;
											document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.email'].disabled = true;

										}

									}//for
								}//if
					    }//elseif

				  } //else

			}//for
				if( selectedContactPerson == -1)
				{
						if(idValue == -1 )
						{
							var id = document.endUserForm['endUser.shippingLocations['+indexValue+'].locAddressId'].value ;
							idValue = id ;

						}
                        // Commented by SureshReddy on [09 JUNE 2004] to modify "width=500" to "width=550"
                        // newWindow = window.open ('<%=chipTracContext%>/addNewEndUserContactPerson.do?value=Address&endUserId='+idValue,'shipLocOptionsPopup11','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=yes,scrollbars=yes,width=500,height=500,resizable=no');
                        // Modified "width=500" to "width=550" by SureshReddy on [09 JUNE 2004] for alignment
						newWindow = window.open ('<%=chipTracContext%>/addNewEndUserContactPerson.do?value=Address&endUserId='+idValue,'shipLocOptionsPopup11','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=yes,scrollbars=yes,width=550,height=500,resizable=no');
						if(!newWindow.opener) {newWindow.opener = window}
						newWindow.focus();

						document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPerson'].value = '';
						document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.phoneNumber'].value = '';
						document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.cellNumber'].value = '';

						document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.faxNumber'].value = '';
						document.endUserForm['endUser.shippingLocations['+indexValue+'].contactPersonObject.email'].value = '';


				}

			}//if( element =='ShippingLocationContactPerson' )

   }//fn

   function selectEndUserPartNumbers()
   {
         var endUserId =  document.endUserForm['endUser.endUserId'].value ;
         newWindow = window.open ('<%=chipTracContext%>/endUserPartNumbers.do?endUserId='+endUserId,'optionsPopup3','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=yes,scrollbars=yes,width=650,height=650,resizable=no');
         if(!newWindow.opener) {newWindow.opener = window}
         newWindow.focus();
   }

function closeWindow() {
    window.opener.document.customerForm.submit();
 	window.close();
}

</script>


<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
  <TR>

<TD bgcolor="#ffffff">
<IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
<TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
<TD valign="top" width="100%">

<IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
<BR>
<!-- from here your body starts -->

<html:form name="endUserForm" method="post" action="/endUser.do"  type="com.scalar.chiptrack.sales.forms.EndUserForm" onsubmit="">


<nested:nest property="endUser" >

<center><span class="NArialW">End User Profile</span></center>
<img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20>

<nested:hidden property="endUserId" />
<nested:hidden property="customerId" />

<table border="0" width="90%" align=right>

<!--Bhaskar added this scriptlet on 17 july 2003-->
<% if ( !user1.isActionAllowed ( Functionality.CUSTOMER_DETAILS,User.USER_ACTION_MODIFY ) ) { %>
 <tr><td colspan=7 align='left'><font class='NArialS'>
 <font color='blue'><b><%=Constants.NO_MODIFY_RIGHTS %></b>
 </font></td></tr> <% } %>
 <tr><td colspan='7' id='errorMessagesId'><chiptrack:errors styleClass="NArialL" /></td></tr>
 <tr><td colspan='7' id='infoMessagesId'><chiptrack:info styleClass='NArialL' /></td></tr>
 <tr><td colspan='7' align=right><a href="javascript:closeWindow();" onMouseOver="window.status='Click here to close this window';return true" onmouseout="window.status='';return true"><font class='NArialL'>Close this window</font></a></td></tr>
 <tr><td colspan='7' align="left" class='NArialL'><FONT id="errors" styleClass="NArialL" color='FF0000'></FONT></TD></TR>

  <tr>
    <td width="20%"><font class="NArialL" >End User Name<font color=red>*</font></font></td>
    <td width="20%"><font class="NArialL" >
    <nested:text property="endUserName" styleClass="txfield" maxlength="50"/>
    </td>

    <td width="8%">&nbsp;</td>
     <td colspan="2"><font class="NArialL">Please &nbsp;&nbsp;<a styleClass="leftsection" href="javascript:selectEndUserPartNumbers()" onmouseover="window.status='Click to enter End Uer Part Number';return true" onmouseout="window.status='';return true">
	 click here</a>&nbsp;&nbsp;
	       for End User Part Number
		   <%-- <bean:message key="label.customerPartNumber"/> --%>
	 </font>
     </td> <!--% =chipTracContext + "/customerPartNumbers.do?action=SaveCustomerPartNo-->

	</font></td>
  </tr>


  <tr>
  <td colspan=4>
  <%-- <img src="<chipTracContext>/jsp/includes/images/spacer.gif" height=10> --%>
  </td>
  </tr>

  <tr><td colspan=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
  <tr>
    <td width="20%" bgcolor="#DEE1E2" colspan=5><font class="NArialL" >Default Billing Address:</font></td>
  </tr>

  <nested:hidden property="defaultBillingAddressId" />
  <nested:hidden property="billAddressId" />
  <nested:nest property="billingAddress">

  <tr>
    <td width="20%"><font class="NArialL" >Address 1</font></td>
    <td width="20%">
  	<nested:text property="address1" size="23" styleClass="txfield" maxlength="50"/>
    </td>
    <td width="8%"></td>
    <td width="20%"><font class="NArialL" >Address 2</font></td>
    <td width="32%">
  	<nested:text property="address2" size="23" styleClass="txfield" maxlength="50"/>
    </td>
  </tr>
   <tr>
    <td width="20%"><font class="NArialL" >Address 3</font></td>
    <td width="20%">
    <nested:text property="address3" size="23" styleClass="txfield" maxlength="50"/>
    </td>
    <td width="8%"></td>
    <td width="20%"><font class="NArialL" >Address 4</font></td>
    <td width="32%">
    <nested:text property="address4" size="23" styleClass="txfield" maxlength="50"/>
    </td>
  </tr>
  <tr>
    <td width="20%"><font class="NArialL" >City</font></td>
    <td width="20%">
  	<nested:text property="city" size="23" styleClass="txfield" maxlength="50"/>
    </td>
    <td width="8%"></td>
    <td width="20%"><font class="NArialL" >State</font></td>
    <td width="32%">
  	<nested:text property="state" size="23" styleClass="txfield" maxlength="50" />
    </td>
  </tr>
  <tr>
    <td width="20%"><font class="NArialL" >Zip</font></td>
    <td width="20%">
  	<nested:text property="zipCode" size="23" styleClass="txfield" maxlength="50"/>
    </td>
    <td width="8%"></td>
    <td width="20%"><font class="NArialL" >Country</font></td>
    <td width="32%">
  	<nested:text property="country" size="23" styleClass="txfield" maxlength="50"/>
    </td>
  </tr>
  <tr>
    <td width="20%"><font class="NArialL" >Contact Person</font></td>
    <td width="20%">

	<!-- modified by Sarada on 8th March 2004 -->
	<nested:select property="contactPerson" styleClass="txfield" onchange="javascript:selectContactPerson('BillingContactPerson',0,0);">
		<html:option value="" />
		<html:option value="-1" >--Edit Contact Person--</html:option>
		<html:option value="" />
		<html:options name="billingContactPersonsList" />
	</nested:select>
	</td>
	</nested:nest>
    <nested:nest property="billingContactPersonObject">

    <td width="8%">&nbsp;</td>
    <td width="20%"><font class="NArialL" >Phone No</font></td>
    <td width="32%"><font class="NArialL" ><nested:text property="phoneNumber" size="20" styleClass="txfield" maxlength="50" onkeypress='validatePhoneNumber(this)'/></font></td>
  </tr>

  <tr>
    <td width="20%"><font class="NArialL" >Cell No</font></td>
    <td width="20%"><nested:text property="cellNumber" size="23" styleClass="txfield" maxlength="50" onkeypress='validatePhoneNumber(this)'/></td>
    <td width="8%"></td>
    <td width="20%"><font class="NArialL" >Fax No</font></td>
    <td width="32%"><nested:text property="faxNumber" size="20" styleClass="txfield" maxlength="50" onkeypress='validatePhoneNumber(this)'/></font></td>
  </tr>

   <tr>
    <td width="20%"><font class="NArialL" >Email</font></td>
    <td width="20%"><nested:text property="email" size="20" styleClass="txfield" maxlength="50" /></font></td>
    <td width="8%">&nbsp;</td>
    <%--
    <td width="20%"><font class="NArialL" >Address</font></td>
    <td width="32%"><nested:text property="address" size="20" styleClass="txfield" maxlength="50" /></font></td>
    --%>
  </tr>

  </nested:nest>


  <tr><td colspan=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
  <tr>
    <td width="20%" bgcolor="#DEE1E2" colspan=5><font class="NArialL" >Default Shipping Address:</font>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <font class="Arial Narrow" size="-1">
    <input type="checkbox" name="sameas" value="yes" onclick="javascript:applyBillingAddress();">
               (Same as billing address) </font>
    </td>
  </tr>
  <nested:hidden property="defaultShippingAddressId" />
  <nested:hidden property="shipAddressId" />
  <nested:nest property="shippingAddress">

  <tr>
    <td width="20%"><font class="NArialL" >Address 1</font></td>
    <td width="20%">
  	<nested:text property="address1" size="23" styleClass="txfield" maxlength="50"/>
    </td>
    <td width="8%"></td>
    <td width="20%"><font class="NArialL" >Address 2</font></td>
    <td width="32%">
  	<nested:text property="address2" size="23" styleClass="txfield" maxlength="50"/>
    </td>
  </tr>
   <tr>
    <td width="20%"><font class="NArialL" >Address 3</font></td>
    <td width="20%">
    <nested:text property="address3" size="23" styleClass="txfield" maxlength="50"/>
    </td>
    <td width="8%"></td>
    <td width="20%"><font class="NArialL" >Address 4</font></td>
    <td width="32%">
    <nested:text property="address4" size="23" styleClass="txfield" maxlength="50"/>
    </td>
  </tr>

  <tr>
    <td width="20%"><font class="NArialL" >City</font></td>
    <td width="20%">
  	<nested:text property="city" size="23" styleClass="txfield" maxlength="50"/>
    </td>
    <td width="8%"></td>
    <td width="20%"><font class="NArialL" >State</font></td>
    <td width="32%">
  	<nested:text property="state" size="23" styleClass="txfield" maxlength="50" />
    </td>
  </tr>
  <tr>
    <td width="20%"><font class="NArialL" >Zip</font></td>
    <td width="20%">
  	<nested:text property="zipCode" size="23" styleClass="txfield" maxlength="50"/>
    </td>
    <td width="8%"></td>
    <td width="20%"><font class="NArialL" >Country</font></td>
    <td width="32%">
  	<nested:text property="country" size="23" styleClass="txfield" maxlength="50"/>
    </td>
  </tr>
  <tr>
    <td width="20%"><font class="NArialL" >Contact Person</font></td>
    <td width="20%">
	<%-- <nested:text property="contactPerson" styleClass="txfield" size="23" maxlength="50"/> --%>
	 <!-- modified by Sarada on 14th April 2004 -->
    <nested:select property="contactPerson" styleClass="txfield" onchange="javascript:selectContactPerson('ShippingContactPerson',document.endUserForm['endUser.defaultShippingAddressId'].value,0
	);">
        <html:option value="" />
        <html:option value="-1" >--Edit Contact Person--</html:option>
        <html:option value="" />
        <html:options name="shippingContactPersonsList"/>
    </nested:select>
    </td>
	</nested:nest>
	<nested:nest property="shippingContactPersonObject"> 
    <td width="8%"></td>
    <td width="20%"><font class="NArialL" >Phone No</font></td>
    <td width="32%">
    	<nested:text property="phoneNumber" styleClass="txfield" size="23" maxlength="50" onkeypress='validatePhoneNumber(this)'/>
    </td>
  <tr>
    <td width="20%"><font class="NArialL" >Cell No</font></td>
    <td width="20%">
	<nested:text property="cellNumber" styleClass="txfield" size="23" maxlength="50" onkeypress='validatePhoneNumber(this)'/>
    </td>
    <td width="8%"></td>
    <td width="20%"><font class="NArialL" >Fax No</font></td>
    <td width="32%">
   <nested:text property="faxNumber" size="23" styleClass="txfield" maxlength="50" onkeypress='validatePhoneNumber(this)'/>
    </td>
  </tr>
  <tr>
    <td width="20%"><font class="NArialL" >Email</font></td>
    <td width="20%">
  	<nested:text property="email" size="23" styleClass="txfield" maxlength="50" />
    </td>
    <td width="8%"></td>
    <td width="20%"></td>
    <td width="32%"></td>
  </tr>
  </nested:nest>


  <% int i=0;
  %>
  <nested:iterate property="shippingLocations">
  <tr><td colspan=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></td></tr>
   <input type="hidden" name="count" value='<%=i%>' />
  <tr>
    <td colspan=5 bgcolor="#DEE1E2"><font class="NArialL" >Shipping Address - <%=++i%>:</font>
	<nested:hidden property="locAddressId" />
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <nested:checkbox property="remove" value="true" /> <FONT class='NArialL'>Remove </FONT>
    &nbsp;&nbsp;&nbsp;&nbsp;
    <font class="Arial Narrow" size="-1">
    <nested:checkbox property="defaultAddress" value="true"/> Default Shipping Address </font>
    </td>
  </tr>
  <tr>
    <td width="20%"><font class="NArialL" >Address 1</font></td>
    <td width="20%">
	<nested:text property="address1" styleClass="txfield" size="23" maxlength="50"/>
    </td>
    <td width="8%"></td>
    <td width="20%"><font class="NArialL" >Address 2</font></td>
    <td width="32%">
	<nested:text property="address2" styleClass="txfield" size="23" maxlength="50"/>
    </td>
  </tr>
   <tr>
    <td width="20%"><font class="NArialL" >Address 3</font></td>
    <td width="20%">
    <nested:text property="address3" size="23" styleClass="txfield" maxlength="50"/>
    </td>
    <td width="8%"></td>
    <td width="20%"><font class="NArialL" >Address 4</font></td>
    <td width="32%">
    <nested:text property="address4" size="23" styleClass="txfield" maxlength="50"/>
    </td>
  </tr>

  <tr>
    <td width="20%"><font class="NArialL" >City</font></td>
    <td width="20%">
	<nested:text property="city" styleClass="txfield" size="23" maxlength="50"/>
    </td>
    <td width="8%"></td>
    <td width="20%"><font class="NArialL" >State</font></td>
    <td width="32%">
	<nested:text property="state" styleClass="txfield" size="23" maxlength="50" />
    </td>
  </tr>
  <tr>
    <td width="20%"><font class="NArialL" >Zip</font></td>
    <td width="20%">
	<nested:text property="zipCode" styleClass="txfield" size="23" maxlength="50"/>
    </td>
    <td width="8%"></td>
    <td width="20%"><font class="NArialL" >Country</font></td>
    <td width="32%">
    <nested:text property="country" styleClass="txfield" size="23" maxlength="50"/>
    </td>
 <tr>
    <td width="20%"><font class="NArialL" >Contact Person</font></td>
    <td width="20%">
	<%-- <nested:text property="contactPerson" styleClass="txfield" size="23" maxlength="50"/> --%>
	<%
		String test = "javascript:selectContactPerson('ShippingLocationContactPerson', document.endUserForm['endUser.shippingLocations["+ (i-1) + "].addressId'].value, "+(i-1)+")";
	%>

	<nested:select property="contactPerson" styleClass="txfield" onchange="<%=test%>" >
        <html:option value="" />
        <html:option value="-1" >--Edit Contact Person--</html:option>
        <html:option value="" />
        <nested:options property="contactPersons"/>
    </nested:select>
    </td>
	<nested:nest property="contactPersonObject"> 
    <td width="8%"></td>
    <td width="20%"><font class="NArialL" >Phone No</font></td>
    <td width="32%">
    <nested:text property="phoneNumber" styleClass="txfield" size="23" maxlength="50" onkeypress='validatePhoneNumber(this)'/>
    </td>
  <tr>
    <td width="20%"><font class="NArialL" >Cell No</font></td>
    <td width="20%">
	<nested:text property="cellNumber" styleClass="txfield" size="23" maxlength="50" onkeypress='validatePhoneNumber(this)'/>
    </td>
    <td width="8%"></td>
    <td width="20%"><font class="NArialL" >Fax No</font></td>
    <td width="32%">
   <nested:text property="faxNumber" size="23" styleClass="txfield" maxlength="50" onkeypress='validatePhoneNumber(this)'/>
    </td>
  </tr>
  <tr>
    <td width="20%"><font class="NArialL" >Email</font></td>
    <td width="20%">
  	<nested:text property="email" size="23" styleClass="txfield" maxlength="50" />
    </td>
    <td width="8%"></td>
    <td width="20%"></td>
    <td width="32%"></td>
  </tr>
  </nested:nest>
  <nested:hidden property="addressId" />
  </nested:iterate>

  <input type="hidden" name="locSize" value="<%=i%>" >

  <tr> <td colspan=5><nested:submit property="addShippingLocation">Add Location</nested:submit></td></tr>

  <tr><td colspan=5>
	  <font id=font1>&nbsp;&nbsp;</font>
  </td></tr>

</table>
<input type="hidden" name="counter" value="2">
<input type="hidden" name="action" value="" />
</nested:nest>

  <tr><td colspan=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=30></td></tr>
  <tr><td colspan=5 align=center>
        <%-- Commented by Krishna Prasad on 20 May 2004, due to improper submition of form --%>
        <%--<chiptrack:restrictedLink functionality='<%=Functionality.CUSTOMER_DETAILS%>' action='<%=User.USER_ACTION_MODIFY%>' styleClass="leftsection" href="javascript:submitpage(document.endUserForm);" onmouseover="window.status='Click to create a new endUser';return true" onmouseout="window.status='';return true"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/save.gif"/></chiptrack:restrictedLink>--%>
        <%-- Added by Krishna Prasad on 20 May 2004, due to above commented tag is not submiting the form properly--%>
        <!-- Commented by SureshReddy on [09 JUNE 2004] due to this line record is saving 2 times-->
        <!--<input type="image" onClick="return submitpage(document.endUserForm);"  border="0" src="<%=chipTracContext%>/jsp/includes/images/save.gif" width="53" height="17" onmouseover="window.status='Click to create a new contact person';return true" onmouseout="window.status='';return true">-->

        <!-- Added by SureshReddy on [09 JUNE 2004] to save record 1 time-->
        <%--<a href="#" onClick="javascript:return submitpage(document.endUserForm);" onmouseover="window.status='Click to Save End User';return true" onmouseout="window.status='';return true"title="Click here to Save End User"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/save.gif"/></a> --%>
        <chiptrack:restrictedLink functionality='<%=Functionality.CUSTOMER_DETAILS%>' action='<%=User.USER_ACTION_MODIFY%>' styleClass="leftsection" href="javascript:submitpage(document.endUserForm);" onmouseover="window.status='Click to Save End User';return true" onmouseout="window.status='';return true"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/save.gif" title="Click here to Save End User"/></chiptrack:restrictedLink>
      	   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <a href="javascript:document.endUserForm.reset();" onmouseover="window.status='Click to Reset';return true" onmouseout="window.status='';return true"title="Click here to reset"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/reset.gif"></a>

  </td></tr>

</html:form>

</TR>
</TABLE>

</BODY>
</HTML>
